﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using Server_NhaSach.DataTransferObject;
using Server_NhaSach.DataAccess.LogicLayer;

namespace Server_NhaSach.BusinessLayer
{
    [Serializable]
    public class PhieuKHTraHangBlo
    {
        #region "Khai báo các biến"
        private PhieuKHTraHangDAO da;
        private PhieuKHTraHangDTO _KHTH;
        private string _error;
        #endregion
        #region "Khai báo các thuộc tính"
        public string Error
        {
            get { return _error; }
        }
        public PhieuKHTraHangDTO KHTH
        {
            get { return _KHTH; }
            set { _KHTH = value; }
        }
        #endregion
        #region "Khai báo các Method"
        public PhieuKHTraHangBlo()
        {            
            da = new PhieuKHTraHangDAO();
        }
        public bool InsertPhieuKHTraHang(string makhth, string manv, string makho,string maKH, string nguoitra, string masothue, string diachi, DateTime ngaytra, string chungtutra, string ghichu, double tongthanhtien)
        {
            _KHTH = new PhieuKHTraHangDTO(makhth, manv, makho,maKH, nguoitra, masothue, diachi, ngaytra, chungtutra, ghichu, tongthanhtien);
            if (!da.InsertPhieuKHTraHang(KHTH))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        public bool UpdatePhieuKHTraHang(string makhth, string manv, string makho,string maKH, string nguoitra, string masothue, string diachi, DateTime ngaytra, string chungtutra, string ghichu, double tongthanhtien)
        {
            _KHTH = new PhieuKHTraHangDTO(makhth, manv, makho, maKH, nguoitra, masothue, diachi, ngaytra, chungtutra, ghichu, tongthanhtien);
            if (!da.UpdatePhieuKHTraHang(KHTH))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        public bool DeletePhieuKHTraHang(string maKHTH)
        {
            if (!da.DeletePhieuKHTraHang(maKHTH))
            {
                _error = da.Error;
                return false;
            }
            return true;
        }
        public DataSet LayDS_PhieuKHTraHang()
        {
            DataSet ds = new DataSet();
            ds = da.LayDS_PhieuKHTraHang();
            return ds;
        }
        #endregion 
    }
}